<?php
/**
 +------------------------------------------------------------------------------
 * 异常处理类
 +------------------------------------------------------------------------------
 */
class IException
{
    /**
     +----------------------------------------------------------
     * 创建异常信息，并且设定异常级别
     +----------------------------------------------------------
     * @param string $message 异常信息
     * @param string $level   异常CODE
     +----------------------------------------------------------
     * @return void
     +----------------------------------------------------------
     */
    public static function set($message, $filename, $lineno) {
    	if(LOG_STATUS){
		    Log::record('==========================异常错误开始===========================','red');
		    Log::record('错误文件/命令：'.$filename,'red');
		    Log::record('错误位置：'.$lineno,'red');
		    Log::record('错误信息：'.$message,'red');
		    Log::record('==========================异常错误结束===========================','red');
		    Log::view();
		    exit;
    	}else{
    		//header('Location: /error/error404');
    		die("404");
    	}
    }
    
	/**
     +----------------------------------------------------------
     * 创建异常信息，并且设定异常级别
     +----------------------------------------------------------
     * @param string $message 异常信息
     * @param string $level   异常CODE
     +----------------------------------------------------------
     * @return void
     +----------------------------------------------------------
     */
    public static function setDB($message, $sql, $filename, $lineno) {
    	if(LOG_STATUS){
		    Log::record('==========================异常错误开始===========================','red');
		    Log::record('错误文件/命令：'.$filename,'red');
		    Log::record('错误位置：'.$lineno,'red');
		    Log::record('错误命令：'.$sql,'red');
		    Log::record('错误信息：数据库操作错误，错误信息为【'.$message.'】','red');
		    Log::record('==========================异常错误结束===========================','red');
		    Log::view();
		    exit;
    	}else{
    		//header('Location: /error/error502');
    		die("502");
    	}
    }
}
?>